<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>侦听器的引入</title>
</head>
<body>
<div id="app">
    <!--  无论是 familyName 还是 firstName变化都会引起  fullName 的更新  -->
    <!--  但是，发现了 fullName 发生变化，却不知道是哪个变化引起的  -->
    <div>
        姓氏：
        <input type="text" name="familyName" id="familyName" v-bind:value="familyName" v-on:input="onFamilyName">
    </div>

    <div>
        名字：
        <input type="text" name="firstName" id="firstName" v-bind:value="firstName" v-on:input="onFirstName">
    </div>

    <div>
        姓名：{{ fullName }}
    </div>
</div>
<script src="../../../../../js/vue.global.js"></script>
<script>
    const app = Vue.createApp({
        data() {
            return {
                familyName: null,
                firstName: null,
            }
        },
        methods: {
            onFamilyName() {
                let family = document.getElementById("familyName")
                this.familyName = family.value
            },
            onFirstName() {
                let first = document.getElementById("firstName")
                this.firstName = first.value
            },
        },
        computed: {
            fullName() {
                return this.familyName + " " + this.firstName
            }
        }
    })

    app.mount("#app")
</script>
</body>
</html>